Thread: C vs. C++ [Speed]

  1. #1
    Registered User bradszy's Avatar
    Join Date
    Jan 2008
    Posts
    114

    C vs. C++ [Speed]

    I'm about to start writing an app, solely based on strings and string manipulation, with speed as my main priority.
    With this in mind, I don't know which would be faster; C, or C++?
    Opinions are appreciated.
    OS: Windows XP Home Edition SP3, Windows 7 Ultimate Beta Build 7000
    LANGUAGES: C++, VB6
    SKILL: Novice/Intermediate

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    If you ask an expert here, they'll agree that C and C++ are just about equally fast.
    You merely need to know how to us the tools correctly.
    I would like to vote for C++, however, simply because it's more feature rich and easier to work with.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User bradszy's Avatar
    Join Date
    Jan 2008
    Posts
    114
    I guess you're probably right, as most C code can be compiled in a C++ compiler, that would mean it would be the same speed.
    But as you say
    You merely need to know how to use the tools correctly.
    it gets me thinking, does either language have different/faster/slower functions based on the subject of string manipulation?
    Or do they both use the same functions, or are the language-specific functions slower?
    OS: Windows XP Home Edition SP3, Windows 7 Ultimate Beta Build 7000
    LANGUAGES: C++, VB6
    SKILL: Novice/Intermediate

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It all depends on the implementation, but you will probably find that std::string is no slouch in speed either, and probably simplifying a great deal of things.
    The real power of C++ also lies in its templates, which when used correctly can do a lot of things at compile time.

    But I would suggest that you try code, profile its speed, apply optimizations and see if the speed is sufficient.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User bradszy's Avatar
    Join Date
    Jan 2008
    Posts
    114
    Ok, i'll try it.
    Thankyou!
    OS: Windows XP Home Edition SP3, Windows 7 Ultimate Beta Build 7000
    LANGUAGES: C++, VB6
    SKILL: Novice/Intermediate

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    C and Caml (a functional language), are two of the fastest languages, with C++ just a whisker behind, with well designed programs.

    I wouldn't worry about the speed of either language. Modern cpu's have more power than you can imagine, with still more to come, in the near future. Making your program multi-threaded and able to run in parallel, would be something that would really make a huge run-time difference in your program.

  7. #7
    Registered User bradszy's Avatar
    Join Date
    Jan 2008
    Posts
    114
    I was considering writing it multi thread.
    I did a search on some tuts, and I found: http://www.adrianxw.dk/SoftwareSite/index.html
    Which covers the basics of Win32 multi threading.
    Know anywhere else I can get some tutorials?
    Thanskyou!
    OS: Windows XP Home Edition SP3, Windows 7 Ultimate Beta Build 7000
    LANGUAGES: C++, VB6
    SKILL: Novice/Intermediate

Popular pages Recent additions subscribe to a feed